<!--信息管理·发展历史-->

#include('head.html')
	<style>
		header a{
			height: 44px;
			margin-bottom: 1px;
		}
		header .am-active a{
			color: #f37b1d !important;
		}
	</style>
	</head>
	#if(page>developments.totalPages)
	<script>
		window.location.href="/backstage/substance?key=${search}&page=${developments.totalPages}";
	</script>
	#end

	<body>
		<div class="admin-content-body">
			<div class="am-cf am-padding am-padding-bottom-0">
				<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">信息管理</strong><small></small></div>
			</div>
			<header class="am-topbar" style="background:none;margin-top: -50px;border-color:#eee;">
				<button type="button" class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

				<div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
					<ul class="am-nav am-nav-pills am-topbar-nav" style="margin-left:20px;font-size:13px;">
						<li class="am-active"><a>发展历史</a></li>
						<li class="aboutus"><a>关于我们</a></li>
					</ul>
				</div>
			</header>


			<div class="am-g">
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							#if(search=="")
							<button type="button" class="am-btn am-btn-default btnAdd">
								<span class="am-icon-plus"></span> 新增
							</button>
							#else
							<button type="button" class="am-btn am-btn-default" onclick="location.href='/backstage/substance'">
								<span class="am-icon-chevron-left"></span> 返回
							</button>
							#end
							<button type="button" style="display:none;" class="am-btn am-btn-default am-text-danger morecheck deleteMore">
								<span class="am-icon-trash-o"></span> 删除
							</button>
						</div>
					</div>
				</div>
				<div class="am-u-sm-12 am-u-md-3">

				</div>
				<div class="am-u-sm-12 am-u-md-3">
					<div class="am-input-group am-input-group-sm">
						<input type="text" style="color:red;" placeholder="请输入标题关键字" id="con" class="am-form-field" value="${search}">
						<span class="am-input-group-btn">
           					<button type="button" class="am-btn am-btn-default search" type="button">搜索</button>
          				</span>
					</div>
				</div>
			</div>
			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<input type="hidden" name="ids" id="ids">
						<table class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
									<th class="table-check"><input class="chooseall" type="checkbox"></th>
									<th class="table-id">ID</th>
									<th class="table-title">标题</th>
									<th class="table-author am-hide-sm-only">内容</th>
									<th class="table-author am-hide-sm-only">地点</th>
									<th class="table-date am-hide-sm-only">时间</th>
									<th class="table-set">操作</th>
								</tr>
							</thead>
							<tbody>
							#for(Development develop : developments.getRows())
								<tr>
									<td><input type="checkbox" name="checkbox" value="${develop.d_id}"></td>
									<td>${develop.d_id}</td>
									<td>
										<a onclick="editHistory(${develop.d_id})">$!{develop.d_title}</a>
									</td>
									<td class="am-hide-sm-only">$!{develop.d_content}</td>
									<td class="am-hide-sm-only">$!{develop.d_place}</td>
									<td class="am-hide-sm-only">${develop.d_time}</td>
									<td>
										<div class="am-btn-toolbar">
											<div class="am-btn-group am-btn-group-xs">
												<button type="button" onclick="editHistory(${develop.d_id})" class="am-btn am-btn-default am-btn-xs am-text-secondary btnedit"><span class="am-icon-pencil-square-o"></span> 编辑</button>
												<button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only deleteThis"><span class="am-icon-trash-o"></span> 删除</button>
											</div>
										</div>
									</td>
								</tr>
							#end
							#if(developments.getTotalRows()==0)
							<tr><td class="am-hide-sm-only"></td><td></td><td></td><td></td><td>暂无记录！</td><td></td><td class="am-hide-sm-only"></td></tr>
							#end
							</tbody>
						</table>
						<div class="am-cf">
							共 ${developments.getTotalRows()} 条记录
							#if(search!="")(查询结果）
							#end
							<div class="am-fr">
								<ul class="am-pagination">
									<li class="${developments.isHasPrevPage()  ? '':'am-disabled'}">
										<a href="/backstage/substance?key=${search}&page=${developments.getPrevPage()}">«</a>
									</li>
									#set(j=developments.getPageNum()-(developments.getPageNum()%5!=0?developments.getPageNum()%5:5)+1)
									#for(int i : range(j, (j+4) > developments.totalPages ? developments.totalPages : j+4))
									<li class="${i == developments.pageNum  ? 'am-active':''}">
										<a href="/backstage/substance?key=${search}&page=${i}">${i}</a>
									</li>
									#end
									<li class="${developments.isHasNextPage()  ? '':'am-disabled'}">
										<a href="/backstage/substance?key=${search}&page=${developments.getNextPage()}">»</a>
									</li>
								</ul>
							</div>
						</div>
						<hr>
					</form>
				</div>
			</div>
		</div>
		#include('/backstage/footer.html')
		<script type="text/javascript" src="/static/js/backstage/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="/static/js/backstage/amazeui.min.js"></script>
		<script type="text/javascript" src="/static/js/backstage/choose.js" ></script>
		<script type="text/javascript" src="/static/js/backstage/plugs.js" ></script>
		<script>
		function editHistory(id) {
			$.jq_Panel({
				title: "编辑信息",
				iframeWidth: 500,
				iframeHeight: 360,
				url: "editHistory/"+id
			});
		}

		function check(){
			var checkID = [];//定义一个空数组
			$("input[name='checkbox']:checked").each(function(j){//把所有被选中的复选框的值存入数组
				 checkID[j] =$(this).val();
			});
			$("#ids").val(checkID);
		}

		$(function() {

			$(".aboutus").click(function() {
					$.jq_Panel({
						title: "关于我们",
						iframeWidth: 500,
						iframeHeight: 300,
						url: "aboutus"
					});
			});

			$(".btnAdd").click(function() {

					$.jq_Panel({
						title: "新增信息",
						iframeWidth: 500,
						iframeHeight: 360,
						url: "addHistory"
					});
			});

			$(".search").click(function(){
			    window.location.href="/backstage/substance?key="+$("#con").val();
			});

			$(".deleteThis").click(function() {
				if(confirm('确定删除吗？')){
					$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
					$.ajax({
						url:"/backstage/history_delete",
						dataType:"json",
						type:"post",
						data:$("form").serialize(),
						success:function(result){
							alert("删除成功！");
							window.location.href=location.href;
						},
						error:function(result){
							alert("系统繁忙！");
						 }
					});
					<!--$(this).parents("tr").remove();-->
				}
			});
			$(".deleteMore").click(function() {
				if(confirm('确定批量删除吗？')){
					check();
					$.ajax({
						url:"/backstage/history_delete",
						dataType:"json",
						type:"post",
						data:$("form").serialize(),
						success:function(result){
							alert(result.tips+"条信息删除成功！");
							window.location.href=location.href;
						},
						error:function(result){
							alert("系统繁忙！");
						 }
					});
					<!--$('tbody input[type=checkbox]:checked').parents("tr").remove();-->
					$("thead input[type='checkbox']").prop("checked", true).click();
				}
			});
		});
		</script>
	</body>
</html>